<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini"  onload="checkBrowser()">

<!--选择执行填写区位模态框-->
<div class="modal fade" id="modal-exec">
    <div class="modal-dialog" style="width: 350px;height: 130px">
        <div class="modal-content">
            <div class="modal-header" style="padding-bottom: 0px;">
                <button type="button" class="close" data-dismiss="modal" title="点击此处取消执行" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新区位编辑</h4>
            </div>
            <div class="modal-body" style="padding-bottom: 5px;padding-top: 0px;">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header" style="padding-bottom: 0px!important;">
                            </div>
                            <div class="box-body"
                                 style="padding-top: 0px;padding-bottom: 0px;height: 50px">
                                <form id="positionForm">
                                    <div class="row">
                                        <div class="form-inline">
                                            <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                                <label>新区位</label>
                                                <input type="text" name="ityPosition"
                                                       class="form-control"
                                                       placeholder="请输入新区位"/>
                                                <input type="hidden" name="ipmIds"
                                                       style="display: none"/>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button type="button" class="btn btn-warning" id="btn-exec-commit">更改区位并执行</button>
                <button type="button" class="btn btn-success" id="btn-exec-cancel">不更改区位执行</button>
            </div>
        </div>
    </div>
</div>
<!--选择外购件库存模态框-->
<div class="modal fade" id="modal-reject-panel">
    <div class="modal-dialog" style="width: 500px;">
        <div class="modal-content">
            <div class="modal-header" style="padding-bottom: 0px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">驳回原因</h4>
            </div>
            <div class="modal-body" style="padding-bottom: 5px;padding-top: 0px;">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header" style="padding-bottom: 0px!important;">

                            </div>
                            <div class="box-body"
                                 style="padding-top: 0px;padding-bottom: 0px;">
                                <form id="modalForm" class="form-horizontal">
                                    <div class="row">
                                        <input type="hidden" name="ipmId">

                                        <div class="form-group" style="height: 60px">
                                            <label style="width: 90px;text-align: right" for="ipmRejectReason">
                                                驳回原因
                                            </label>
                                            <label>
                                                <input type="text" id="ipmRejectReason" name="ipmRejectReason"
                                                       value="&nbsp;" maxlength="128"
                                                       class="form-control" style="width: 350px"/>
                                            </label>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button type="button" class="btn btn-info" id="btn-reject-commit">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<section class="content-header">
    <h1 style="display: inline-block" th:if="${totalPrice} == null">库存划项目执行</h1>
    <h1 style="display: inline-block" th:if="${totalPrice} != null" th:text="${month}+'月库存划项目金额:'"></h1>
    <h1 style="display: inline-block" th:if="${totalPrice} != null" th:text="${totalPrice}"></h1>
    <h1 style="display: inline-block" th:if="${totalPrice} != null">万元</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header" style="padding-bottom: 0px">
                    <form id="queryForm" action="/purchase/invPro/exportExcel">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        项目编号
                                    </label>
                                    <label class="control-label">
                                        <input name="ipmInProjectCode" type="text" class="form-control text"

                                               placeholder="请输入项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        项目名称
                                    </label>
                                    <label class="control-label">
                                        <input name="ipmInProjectName" type="text" class="form-control text"
                                               maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        物料描述
                                    </label>
                                    <label class="control-label">
                                        <input name="ityMatDesc" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入物料描述"/>
                                    </label>
                                </div>
                                <!--<div class="form-group" style="margin-right: 10px;margin-bottom: 5px">-->
                                    <!--<label class="control-label" style="text-align: right">-->
                                        <!--物料描述-->
                                    <!--</label>-->
                                    <!--<label class="control-label">-->
                                        <!--<input name="ipmMatDesc" type="text" class="form-control text" maxlength="255"-->
                                               <!--placeholder="请输入物料描述"/>-->
                                    <!--</label>-->
                                <!--</div>-->
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        标记人
                                    </label>
                                    <label class="control-label">
                                        <input name="ipmProposer" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入标记人信息"/>
                                    </label>
                                </div>
                                <div class="form-group" style="padding-right: 10px;padding-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        被标记物料项目编号
                                    </label>
                                    <label class="control-label">
                                        <input name="ityProCode" type="text" class="form-control text"

                                               placeholder="请输入被标记物料项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        执行人
                                    </label>
                                    <label class="control-label">
                                        <input name="ipmExecutor" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入执行人信息"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        区位
                                    </label>
                                    <label class="control-label">
                                        <input name="ityPosition" type="text" class="form-control text" maxlength="255"
                                               placeholder="请输入区位"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        状态
                                    </label>
                                    <label class="control-label">
                                        <select th:if="${mode}==null" name="ipmAppStatus" class="form-control select"
                                                style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 100px!important;">
                                            <option value="-1">全部</option>
                                            <option value="3" selected>未执行</option>
                                            <option value="4">已执行</option>
                                        </select>
                                        <select th:if="${mode}=='index_exec'" name="ipmAppStatus" class="form-control select"
                                                style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 100px!important;">
                                            <option value="4" selected>已执行</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group" style="padding-right: 10px;padding-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        仓库
                                    </label>
                                    <label class="control-label">
                                        <select name="ityWhiId" class="form-control select"
                                                style="padding: 0px!important;text-align: center!important;text-align-last: center!important;">

                                        </select>
                                    </label>
                                </div>
                                <div class="form-group" style="padding-right: 10px;padding-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        标记时间
                                    </label>

                                    <input name="beginDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly"> -
                                    <input name="endDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly">
                                </div>
                                <div class="form-group" style="padding-right: 10px;padding-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        执行时间
                                    </label>

                                    <input name="execBeginDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly"> -
                                    <input name="execEndDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly">
                                </div>
                                <div id="submitDate" class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label class="control-label" style="text-align: right">
                                        提交日期范围
                                    </label>
                                    <label class="control-label">
                                        <input name="beginSubmitDate" type="text" class="form-control datepicker"
                                               style="width:100px!important;text-align: center!important;"
                                               readonly="readonly"/>-
                                        <input name="endSubmitDate" type="text" class="form-control datepicker"
                                               style="width:100px!important;text-align: center!important;"
                                               readonly="readonly"/>
                                    </label>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <button type="button" class="btn btn-success" id="btn-search">搜索
                                    </button>
                                </div>
                            </div>

                        </div>
                    </form>
                </div>
                <div class="row" id="toolbar">
                    <button shiro:hasPermission="purinv:purwarproexec:edit" type="button" class="btn btn-success"
                            onclick="execApply('')">
                        批量执行
                    </button>
                    <button shiro:hasPermission="purinv:purwarproexec:edit" type="button" class="btn btn-danger"
                            onclick="invalid('')">
                        批量驳回
                    </button>
<!--                    <button style="width: 83px;" id="btn_export" type="button" shiro:hasPermission="purinv:purwarproexec:edit" class="btn btn-primary">导出</button>-->
<!--                    <img th:src="@{/img/downloadding.gif}" id="btn_tips" style="display: none"/>-->
                </div>
                <div class="box-body" style="padding-top: 0 ">
                    <table id="bootstrap-table" class="table table-bordered " width="100%">
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;
    var applyStatusText = ["删除", "未提交", "被驳回", "未执行", "已执行"];
    var applyStatusColor = ["", " bg-gray", " bg-red", " bg-gray", " bg-green"];

    function checkBrowserFun() {
        let is360 = false;
        let isIE = false;
        let isFirefox = false;
        let isChrome = false;
        let isEdge = false;
        let broName = 'Runing';
        let str = '';
        let strStart = 0;
        let strStop = 0;
        let arr = new Array();
        let temp = '';
        let userAgent = window.navigator.userAgent; //包含以下属性中所有或一部分的字符串：appCodeName,appName,appVersion,language,platform
        /*alert(userAgent);*/
        //FireFox
        if (userAgent.indexOf('Firefox') != -1) {
            isFireFox = true;
            /*broName = 'FireFox浏览器';*/
            strStart = userAgent.indexOf('Firefox');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号')

        }
        //Edge
        if (userAgent.indexOf('Edge') != -1) {
            isEdge = true;
            /*broName = 'Edge浏览器';*/
            strStart = userAgent.indexOf('Edge');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号');
        }
        //IE浏览器
        if (userAgent.indexOf('NET') != -1 && userAgent.indexOf("rv") != -1) {
            isIE = true;
            /*broName = 'IE浏览器'; */
            strStart = userAgent.indexOf('rv');
            strStop = userAgent.indexOf(')');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('rv', 'IE').replace(':', '版本号');
        }
        //360极速模式可以区分360安全浏览器和360极速浏览器
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") < 0 && userAgent.indexOf("Firefox") < 0) {
            if (navigator.javaEnabled()) {
                is360 = true;
                broName = '360安全浏览器-极速模式';
            } else {
                is360 = true;
                broName = '360极速浏览器-极速模式';
            }
        }
        //360兼容
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") != -1 && userAgent.indexOf("MSIE") != -1 && userAgent.indexOf("rv") < 0) {
            is360 = true;
            broName = '360兼容模式';
        }
        //Chrome浏览器
        if (userAgent.indexOf('WOW') < 0 && userAgent.indexOf('Chrome') > 0 && userAgent.indexOf("Edg") < 0) {
            isChrome = true;
            /*broName = 'Chrome浏览器';*/
            strStart = userAgent.indexOf('Chrome');
            strStop = userAgent.indexOf(' Safari');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('/', '版本号');
        }
        return isChrome;
    }

    /**
     * 检测浏览器
     * */
    function checkBrowser(){
        if(!checkBrowserFun()){
            alert("尊敬的客户，您使用浏览器不是谷歌浏览器，请使用谷歌浏览器访问本系统！");
            location.href=ctx+"overview/index";
        }
    }

    function initConfig() {
        let mode = [[${mode}]];
        if(mode != null){
            $("#queryForm").hide();
            $("#toolbar").hide();
            $("#execBeginDate").val([[${start}]]);
            $("#execEndDate").val([[${end}]]);
            $("#execBeginDate").datepicker('setDate', [[${start}]]);
            $("#execEndDate").datepicker('setDate', [[${end}]]);
        }else {
            $("#queryForm").show();
            $("#toolbar").show();
        }

    }
    /**
     *@FunctionName: findWarehouseList
     *@Description: 获取仓库列表
     *@DesignIdea: 因为此页面是外购件页面，所以获取外购件仓库列表。
     *@Author: 徐一贺
     *@CreateDate: 2020/5/9 16:10
     *@Phone: 18241927380
     *@Param: []
     *@Version: v 1.0.0
     */
    function findWarehouseList() {
        js.ajax({
            url: ctx + 'common/warehouseInfo/list',
            type: 'post',
            traditional: true,            // 阻止深度序列化， 使参数可以使用数组
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            data: {},
            async: true,                // 异步执行
            success: function (result) {
                if (result.type === web_status.SUCCESS) {

                    $("#queryForm [name='ityWhiId']").empty();
                    $("#queryForm [name='ityWhiId']").append('<option selected="selected" style="vertical-align: middle;text-align: center" value="">全部</option>');
                    for (var i = 0; i < result.data.rows.length; i++) {
                        $("#queryForm [name='ityWhiId']").append('<option style="vertical-align: middle;text-align: center" value="' + result.data.rows[i].whiId + '">' + result.data.rows[i].whiName + '</option>');
                    }
                } else {
                    js.modal.warning(result.msg);
                }
            },
            error: function () {
                js.modal.fail();
            }
        })
    }

    function revokeApply(ipmIds) {
        bootbox.confirm("您确认要撤销此标记吗？", function (result) {
            if(result){
                $("#bootstrap-table").hide();
                $("#toolbar").hide();
                $.post(ctx + 'purchase/invPro/revokeApply', {
                    ipmIds: ipmIds
                }, function (result) {
                    if (result.type == "SUCCESS") {
                        js.table.refresh(table);
                        $("#bootstrap-table").show();
                        $("#toolbar").show();
                    } else if (result.type == "ERROR") {
                        js.modal.fail(result.msg);
                        js.table.refresh(table);
                        $("#bootstrap-table").show();
                        $("#toolbar").show();
                    }
                }, 'json');
            }
        });
    }


    /**
     *@FunctionName: execApply
     *@Description: 执行
     *@Author: 徐一贺
     *@CreateDate: 2020/4/21 12:35
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function execApply(ipmIds) {
        if (ipmIds == '') {
            $('input[name="cb_change"]').each(function () {
                if (!$(this).prop("disabled")) {
                    if ($(this).prop("checked")) {
                        ipmIds += $(this).attr("data") + ",";
                    }
                }
            })
            ipmIds = ipmIds.substring(0, ipmIds.length - 1);
        }
        if (ipmIds == '') {
            js.modal.alert("请选择要执行的标记！");
            return;
        }

        ipmIds += '';
        var rowData = $('#bootstrap-table').bootstrapTable('getRowByUniqueId', ipmIds);
        $("#positionForm")[0].reset();
        if (ipmIds.indexOf(",") == -1) {
            $.post(ctx + 'purchase/invPro/getPInventory', {
                ityId: rowData.ityId
            }, function (result) {
                if (result.type == "SUCCESS") {
                    $("#positionForm").fillData(result.data);
                    js.modal.open("modal-exec");
                    $("#positionForm [name='ipmIds']").val(ipmIds);
                }
            }, 'json');
        } else {
            $("#positionForm [name='ipmIds']").val(ipmIds);
            js.modal.open("modal-exec");
        }
    }

    /**
     *@FunctionName: removeAppy
     *@Description: 删除作废
     *@Author: 徐一贺
     *@CreateDate: 2020/4/21 13:09
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function invalid(ipmIds) {
        if(ipmIds===''){
            $('input[name="cb_change"]').each(function () {
                if (!$(this).prop("disabled")) {
                    if ($(this).prop("checked")) {
                        ipmIds += $(this).attr("data") + ",";
                    }
                }
            })
            ipmIds = ipmIds.substring(0, ipmIds.length - 1);
        }
        if (ipmIds == '') {
            js.modal.alert("请选择要驳回的标记！");
            return;
        }
        $("#modalForm [name='ipmId']").val(ipmIds);
        js.modal.open('modal-reject-panel');
    }


    /**
     *@FunctionName: search
     *@Description: 查询
     *@Author: 徐一贺
     *@CreateDate: 2020/4/10 16:10
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function search() {
        js.table.search(table);
    }

    /**
     *@FunctionName: selectAll
     *@Description: 全选
     *@Author: 徐一贺
     *@CreateDate: 2020/4/8 15:20
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function selectAll(obj) {
        $('input[name="cb_change"]').each(function () {
            if (!$(this).prop("disabled")) {
                if ($(obj).prop("checked")) {
                    $(this).prop("checked", true);
                }
                if ($(obj).prop("checked") == false) {
                    $(this).prop("checked", false);
                }
            }
        })

    }


    $(function () {
        $("title").html($("title").html()+" —— 外购件库存划项目执行");
        let columnArr=new Array();
        findWarehouseList();
        initConfig();
        let mode = [[${mode}]];
        if(mode!=null){
            columnArr=[

                {
                    title: '序号', field: 'ipmId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '物料描述', field: 'ityMatDesc', width: '150'},
                {title: '标记数量', field: 'ipmNum'},
                {title: '单位', field: 'ityNumUnit', width: '50'},
                // {title: '提报计划物料标准号', field: 'ipmStandardNo'},
                {
                    title: '项目编号', field: 'ipmInProjectCode', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '项目名称', field: 'ipmInProjectName', width: '150', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },

                {title: '仓库', field: 'ityWhiName'},
                {title: '区位', field: 'ityPosition'},
                {
                    title: '在库类型', field: 'ityStockType', width: '150', formatter: function (value, row, index) {

                        if (value == 1) {
                            return "库存在库";
                        }
                        if (value == 2) {
                            return "项目在库";
                        }
                        return value;
                    }
                },
                {
                    title: '标记人', field: 'ipmProposer', width: '70'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '标记时间', field: 'ipmDatePage', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '被标记物料项目编号', field: 'ityProCode', width: '100'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '提交时间', field: 'ipmSubmitDate', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '执行人', field: 'ipmExecutor', width: '70'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '执行时间', field: 'ipmExecDate', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '划拨说明', field: 'ipmRemark'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                }
            ];
        }else {
            columnArr=[
                {
                    title: '<input style="width: 16px;height: 30px"  title="全选" id="selectAll" onclick="selectAll(this)" type="checkbox" />',
                    width: '30',
                    field: 'ipmId',
                    formatter: function (value, row, index) {
                        var disabled = 'disabled="disabled"';
                        if (row.ipmAppStatus == 3) {
                            disabled = "";
                        }
                        return '<input  style="width: 16px;height: 30px" ' + disabled + ' id="cb_change' + row.ipmId + '" name="cb_change" data="' + row.ipmId + '"  type="checkbox" />';
                    }
                },
                {
                    title: '序号', field: 'ipmId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '物料描述', field: 'ityMatDesc', width: '150'},
                {title: '标记数量', field: 'ipmNum'},
                {title: '单位', field: 'ityNumUnit', width: '50'},
                // {title: '提报计划物料标准号', field: 'ipmStandardNo'},
                {
                    title: '项目编号', field: 'ipmInProjectCode', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '项目名称', field: 'ipmInProjectName', width: '150', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },

                {title: '仓库', field: 'ityWhiName'},
                {title: '区位', field: 'ityPosition'},
                {
                    title: '在库类型', field: 'ityStockType', width: '150', formatter: function (value, row, index) {

                        if (value == 1) {
                            return "库存在库";
                        }
                        if (value == 2) {
                            return "项目在库";
                        }
                        return value;
                    }
                },
                {
                    title: '标记人', field: 'ipmProposer', width: '70'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '标记时间', field: 'ipmDatePage', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '被标记物料项目编号', field: 'ityProCode', width: '100'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '被标记物料项目名称', field: 'ityProName', width: '100'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '提交时间', field: 'ipmSubmitDate', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '执行人', field: 'ipmExecutor', width: '70'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '执行时间', field: 'ipmExecDate', width: '100'
                    , formatter: function (value, row, index) {
                        if(value!=null){
                            return value.substring(0,10);
                        }
                        return '--';
                    }
                },
                {
                    title: '划拨说明', field: 'ipmRemark'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        return value;
                    }
                },
                {
                    title: '状态', field: 'ipmAppStatus'
                    , formatter: function (value, row, index) {
                        if (value == undefined) {
                            return "";
                        }
                        var html = '<label class="badge ' + applyStatusColor[value] + '">' + applyStatusText[value] + '</label>';
                        return html;
                    }
                },
                {
                    title: '操作', field: 'ipmId', width: '110',
                    formatter: function (value, row, index) {
                        var htmlText = "";
                        if (hasP('purinv:purwarproexec:edit')) {
                            if (row.ipmAppStatus == 4) {
                                htmlText += '<button class="btn btn-primary btn-xs" onclick="revokeApply(' + row.ipmId + ')">撤销</button>';
                                return htmlText
                            }
                            if (row.ipmAppStatus == 3) {
                                htmlText += '<button class="btn btn-success btn-xs" onclick="execApply(' + row.ipmId + ')">执行</button>';
                                htmlText += '<button onclick="invalid(' + row.ipmId + ')" class="btn btn-xs btn-danger">驳回</button>';
                            }
                        }
                        return htmlText;
                    }
                }
            ];
        }
        //加载列表数据
        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "purchase/invPro/execList",
            showColumns: true,
            showExport: false,
            pageSize: 300,
            striped: false,
            uniqueId: "ipmId",
            onLoadSuccess: function () {
                $('#inventoryQueryTable thead th').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
                $('#inventoryQueryTable tbody tr:first td').each(function () {
                    $(this).width(Math.floor($(this).width()));
                });
            },
            columns: columnArr
        });
        /**
         * 表格搜索
         */
        $("#btn-search").on('click', function () {
            js.table.search(table);
        });

        $("#btn-reject-commit").on('click', function () {
                $.post(ctx + 'purchase/invPro/invalid', {
                    ipmIds:$("#modalForm [name='ipmId']").val(),
                    ipmRejectReason:$("#modalForm [name='ipmRejectReason']").val()
                }, function (result) {
                    if (result.type == "SUCCESS") {
                        js.modal.hide('modal-reject-panel');
                        js.table.refresh(table);
                    }
                }, 'json');

        });

        $("#btn-exec-commit").on('click', function () {
            $("#bootstrap-table").hide();
            $("#toolbar").hide();
            $.post(ctx + 'purchase/invPro/execApply', {
                ipmIds: $("#positionForm [name='ipmIds']").val(),
                ityPosition: $("#positionForm [name='ityPosition']").val()
            }, function (result) {
                if (result.type == "SUCCESS") {
                    js.table.refresh(table);
                    js.modal.success(result.msg);
                    js.modal.hide("modal-exec");
                    $("#bootstrap-table").show();
                    $("#toolbar").show();
                }
                if (result.type == "ERROR") {
                    js.modal.warning(result.msg);
                    js.modal.fail("请驳回!");
                    js.table.refresh(table);
                    $("#bootstrap-table").show();
                    $("#toolbar").show();
                }
            }, 'json');
        });
        $("#btn-exec-cancel").on('click', function () {
            $("#bootstrap-table").hide();
            $("#toolbar").hide();
            $.post(ctx + 'purchase/invPro/execApply', {
                ipmIds: $("#positionForm [name='ipmIds']").val(),
            }, function (result) {
                if (result.type == "SUCCESS") {
                    js.table.refresh(table);
                    js.modal.success(result.msg);
                    js.modal.hide("modal-exec");
                    $("#bootstrap-table").show();
                    $("#toolbar").show();
                }
                if (result.type == "ERROR") {
                    js.modal.warning(result.msg);
                    js.modal.fail("请驳回!");
                    js.table.refresh(table);
                    $("#bootstrap-table").show();
                    $("#toolbar").show();
                }
            }, 'json');
        });
        $("#btn_export").on('click', function () {
            $("#btn_export").hide();
            $("#btn_tips").show();
            $("#queryForm").submit();
            setTimeout(function () {
                var actionVal = $("#queryForm").attr("action");
                $("#queryForm").removeAttr("action");
                $("#queryForm").attr("action", actionVal);
                $("#btn_tips").hide();
                $("#btn_export").show()
            }, 5000);

        });
    });
</script>
</body>
</html>
